﻿using System;


class Program
{
    static void Main()
    {

        var retry = true;
        while (retry)
        {
            //FULL BODY SPECIFICS
            //Console.WriteLine("     ___");
            //Console.WriteLine("    /   \");
            //Console.WriteLine("   /     \");
            //Console.WriteLine(   /       \);
            //Console.WriteLine(" /  .---.  \");
            //Console.WriteLine("/  /     \\ \");
            //Console.WriteLine("\  \\     /  /");
            //Console.WriteLine(" \    ---   /");
            //Console.WriteLine("  \ ___|___/");
            //Console.WriteLine("    /  |  \");
            //Console.WriteLine("   /   |   \");
            //Console.WriteLine("      _|_");
            //Console.WriteLine("     /   \");
            //Console.WriteLine("    /     \");
            string c = "c";
            string h = "h";
            string a = "a";
            string m = "m";
            string p = "p";
            string i = "i";
            string o = "o";
            string n = "n";
            string hiddenChar = "_";
            bool isCshown = false;
            bool isHshown = false;
            bool isAshown = false;
            bool isMshown = false;
            bool isPshown = false;
            bool isIshown = false;
            bool isOshown = false;
            bool isNshown = false;
            string[] word = new string[8];
            string head = "  .---.\n /     \\\n \\     /\n   ---";
            string upperBody = "   _|_\n    |";
            string lowerBody = "    |\n   _|_";
            string body = "   _|_\n    |\n    |\n   _|_";
            string bodyLefthand = "   _|_\n    |  \\\n    |    \\\n   _|_";
            string bodyBothHands = "   _|_\n /  |  \\\n/   |   \\\n   _|_";
            string bodyLeftLeg = "   _|_\n /  |  \\\n/   |   \\\n   _|_\n      \\\n       \\";
            string bodyBothLegs = "   _|_\n /  |  \\\n/   |   \\\n   _|_\n  /   \\\n /     \\";
            string Hanged = "     ___\n    /   \\\n   /     \\\n  /       \\\n /  .---.   \\\n/  /     \\   \\\n\\  \\     /   /\n \\   ---    /\n  \\ ___|___/\n    /  |  \\\n   /   |   \\\n      _|_\n     /   \\\n    /     \\";
            string Dead = "     ___\n    /   \\\n   /     \\\n  /       \\\n /  .---.   \\\n/  /     \\   \\\n\\  \\     /   /\n \\   ---    /\n  \\ ___|___/\n    |  |  |\n    |  |  |\n      _|_\n     |   |\n     |   |";
            word[0] = hiddenChar;
            word[1] = hiddenChar;
            word[2] = hiddenChar;
            word[3] = hiddenChar;
            word[4] = hiddenChar;
            word[5] = hiddenChar;
            word[6] = hiddenChar;
            word[7] = hiddenChar;
            int lifeCount = 9;
            Console.WriteLine("Enter a command! Type help for list of available commands.");
            string command = Console.ReadLine();
            if (command != "help" & command != "exit" & command != "game")
            {
                Console.WriteLine("There is no such command");

            }
            else if (command == "help" | command == "exit" | command == "game")
            {


                switch (command)
                {
                    case "exit":
                        Console.WriteLine("Goodbye!");
                        Console.WriteLine("Game created by Radostin Angelov.");
                        Console.ReadKey();
                        return;
                        
                        break;
                    case "help":
                        Console.WriteLine("The available commands are:\n- game\n\t ->guess\n\t->lives\n\t->stop\n- exit\n- help");
                        command = Console.ReadLine();
                        if (command == "game")
                        {
                            goto case "game";

                        }
                        if (command == "exit")
                        {
                            Console.WriteLine("Goodbye!");
                            Console.ReadKey();
                            return;

                        }
                        if (command == "help")
                        {
                            goto case "help";
                        }
                        if (command != "game" & command != "help" & command != "exit")
                        {
                            Console.WriteLine("There is no such command!");
                            goto case "help";
                        }
                        break;

                    case "game":
                        Console.WriteLine("So, you want to play a game, Huh?");
                        Console.WriteLine("Guess what word is this :");
                        Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7}", word);
                        if (word[0] == "c" & word[1] == "h" & word[2] == "a" & word[3] == "m" & word[4] == "p" & word[5] == "i" & word[6] == "o" & word[7] == "n")
                        {
                            Console.WriteLine("Congratz, you have beaten the game!");
                            Console.WriteLine("Do you want to play again ?");
                            Console.WriteLine("If yes -> write 1. If no - > write 2.");
                            string play = Console.ReadLine();
                            if (play == "1")
                            {
                                retry = true;
                                Console.Clear();
                                break;
                            }
                            else if (play == "2")
                            {
                                Console.WriteLine("Goodbye!");
                                Console.WriteLine("Game created by Radostin Angelov.");
                                Console.ReadKey();
                                return;
                            }
                        }
                        Console.WriteLine("You mus enter a game command:guess/lives/stop.");
                        string gamecommand = Console.ReadLine();
                        if (gamecommand == "lives")
                        {
                            Console.WriteLine("You have {0} lives left.", lifeCount);
                            goto case "game";
                        }
                        if (gamecommand == "stop")
                        {
                            Console.Clear();
                            Console.WriteLine("Did you really ment to stop the game(if yess -> type 1 / if no -> type 2");
                            string stop = Console.ReadLine();
                            if (stop == "1")
                            {
                                Console.WriteLine("Goodbye!");
                                Console.WriteLine("Game created by Radostin Angelov.");
                                Console.ReadKey();
                                return;
                            }
                            else if (stop == "2")
                            {
                                goto case "game";
                            }

                        }
                        if (gamecommand == "guess")
                        {
                            Console.WriteLine("Enter a letter!");
                            char letter = char.Parse(Console.ReadLine());
                            if (letter == char.Parse(c) | letter == char.Parse(h) | letter == char.Parse(a) | letter == char.Parse(m) | letter == char.Parse(p) | letter == char.Parse(i) | letter == char.Parse(o) | letter == char.Parse(n))
                            {
                                if (letter == 'c')
                                {
                                    isCshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"C\"");
                                    word[0] = "c";
                                }
                                if (letter == 'h')
                                {
                                    isHshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"H\"");
                                    word[1] = "h";
                                }
                                if (letter == 'a')
                                {
                                    isAshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"A\"");
                                    word[2] = "a";
                                }
                                if (letter == 'm')
                                {
                                    isMshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"M\"");
                                    word[3] = "m";
                                }
                                if (letter == 'p')
                                {
                                    isPshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"P\"");
                                    word[4] = "p";
                                }
                                if (letter == 'i')
                                {
                                    isIshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"I\"");
                                    word[5] = "i";
                                }
                                if (letter == 'o')
                                {
                                    isOshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"O\"");
                                    word[6] = "o";
                                }
                                if (letter == 'n')
                                {
                                    isNshown = true;
                                    Console.Clear();
                                    Console.WriteLine("You have revealed the letter \"N\"");
                                    word[7] = "n";
                                }
                            }

                            else
                            {
                                if (letter != char.Parse(c) & letter != char.Parse(h) & letter != char.Parse(a) & letter != char.Parse(m) & letter != char.Parse(p) & letter != char.Parse(i) & letter != char.Parse(o) & letter != char.Parse(n))
                                {
                                    lifeCount--;
                                    Console.Clear();
                                    Console.WriteLine("You made a mistake! Your lives are now {0}", lifeCount);
                                    if (lifeCount == 8)
                                    {
                                        

                                        Console.WriteLine(head);
                                    }
                                    if (lifeCount == 7)
                                    {
                                        Console.WriteLine(head);

                                        Console.WriteLine(upperBody);
                                    }
                                    if (lifeCount == 6)
                                    {
                                        Console.WriteLine(head);
                                        Console.WriteLine(body);
                                    }
                                    if (lifeCount == 5)
                                    {
                                        Console.WriteLine(head);
                                        
                                        Console.WriteLine(bodyLefthand);
                                    }
                                    if (lifeCount == 4)
                                    {
                                        Console.WriteLine(head);
                                        
                                        Console.WriteLine(bodyBothHands);
                                    }
                                    if (lifeCount == 3)
                                    {
                                        Console.WriteLine(head);
                                        Console.WriteLine(bodyLeftLeg);
                                    }
                                    if (lifeCount == 2)
                                    {
                                        Console.WriteLine(head);
                                        Console.WriteLine(bodyBothLegs);
                                    }
                                    if (lifeCount == 1)
                                    {
                                        Console.WriteLine(Hanged);
                                    }
                                    if (lifeCount == 0)
                                    {
                                        Console.WriteLine(Dead);
                                    }
                                }
                            }
                            retry = false;
                            if (lifeCount == 0)
                            {
                                Console.WriteLine("Game Over!");
                                Console.WriteLine("Do you want to play again ?(yes/no)");
                                string playAgain = Console.ReadLine();
                                if (playAgain == "yes")
                                {
                                    retry = true;
                                    break;
                                }
                                else if (playAgain == "no")
                                {
                                    Console.WriteLine("Goodbye!");
                                    Console.WriteLine("Game created by Radostin Angelov.");
                                    Console.ReadKey();
                                    return;
                                }
                            }
                            else
                            {
                                
                                goto case "game";


                            }

                        }
                        if (gamecommand !="guess" & gamecommand !="lives" & gamecommand != "stop")
                        {
                            Console.WriteLine("There is no such command!");
                            goto case "game";
                        }
                        break;
                }

            }
        }

    }
}

